package com.rslai.base.tool.servertest.config;

import com.rslai.base.tool.servertest.annotation.Element;
import com.rslai.base.tool.servertest.annotation.Property;
import com.rslai.base.tool.servertest.command.MockStepCommand;
import com.rslai.base.tool.servertest.command.StepCommand;
import com.rslai.base.tool.servertest.model.KeyValueStore;

import java.util.ArrayList;
import java.util.List;

public class MockStepConfig extends StepConfig {

    @Property(required = true)
    String service;

    @Property
    String key;

    @Property(required = true)
    String target;

    @Property
    String source;

    @Property("return")
    String returnValue;

    @Element
    List<KeyValueStore> params;

    public List<KeyValueStore> getParams() {
        return this.params;
    }

    public StepCommand createCommand() {
        List newParams = new ArrayList();
        newParams.addAll(this.params);
        newParams.add(new KeyValueStore("source", this.source));
        newParams.add(new KeyValueStore("target", this.target));
        newParams.add(new KeyValueStore("key", this.key));
        newParams.add(new KeyValueStore("returnValue", this.returnValue));
        newParams.add(new KeyValueStore("service", this.service));
        this.params = newParams;
        return new MockStepCommand(this.params);
    }
}
